//
//  node.m
//  SSE
//
//  Created by Matt Roman on 3/21/08.
//  Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "node.h"


@implementation node

- (id) initNodeWithID:(int)num point:(Point3f)pt;
{
	[super init];
	visited = NO;
	ObjID = num;
	vertexNumber = -1;
	vertex = pt;
	distance = 0;
	direction = 0;
	parentNode = nil;
	return self;
}

- (bool) visited
{
	return visited;
}

- (void) setVisited:(bool)a
{
	visited = a;
}

- (int) getID
{
	return ObjID;
}

- (int) vertexNumber
{
	return vertexNumber;
}

- (void) setVertexNumber:(int)num
{
	vertexNumber = num;
}

- (void) setPoint:(Point3f)pt
{
	vertex = pt;
}

- (Point3f) getPoint
{
	return vertex;
}

- (Point3f *) getPtrPoint
{
	return &vertex;
}

- (double) distance
{
	return distance;
}

- (void) setDistance:(double)d
{
	distance = d;
}

- (double) direction
{
	return direction;
}

- (void) setDirection:(double)d
{
	direction = d;
}

- (node *) parentNode
{
	return parentNode;
}

- (void) setParentNode:(node *)nd
{
	parentNode = nd;
}

- (NSComparisonResult)compareAngle:(node *)aNode
{
	if(direction < [aNode direction])return NSOrderedAscending;
	else if(direction > [aNode direction])return NSOrderedDescending;
	else return NSOrderedSame;
}

- (NSString *) description
{
	if(vertexNumber < 0) return [NSString stringWithFormat:@"ID %d Vert %@ (%f,%f)",ObjID,(vertexNumber == -1)?@"Left":@"Right",vertex.x,vertex.y];	
	return [NSString stringWithFormat:@"ID %d Vert %d (%f,%f)",ObjID,vertexNumber,vertex.x,vertex.y];		
}

- (void) clear
{
	distance = 0;
	direction = 0;
	parentNode = nil;
}

- (void) dealloc
{
	parentNode = nil;
	[super dealloc];
}
@end
